package org.apple.transmitter;

import java.util.Vector;

import org.apple.data.Position;
import org.apple.data.*;

public class DefaultFormatter implements Formatter {
	
	public static int messageNumber = 0;
	
	public String format(Position position, Vector<SensorReading> averages) {
		
		
		String defaultMessage ="";
		for (int i=0; i<averages.size();i++){
			switch(averages.get(i).getSensorType()){
			case SensorReading.SPEED :
				defaultMessage = defaultMessage + "1,"+averages.get(i).getValue()+";"; 
				break;
			case SensorReading.AIRTEMPRATURE :
				defaultMessage = defaultMessage + "2,"+averages.get(i).getValue()+";"; 
				break;
			case SensorReading.SEATEMPRATURE :
				defaultMessage = defaultMessage + "3,"+averages.get(i).getValue()+";"; 
				break;
				
			}

		}
		if(position != null){
			
			defaultMessage = defaultMessage+"4,"+position.getX()+" "+position.getY()+";";
		}
		
		messageNumber = messageNumber+1;
		
		defaultMessage = defaultMessage+"5,"+messageNumber;
		
		return defaultMessage;
	}

}